//
//  SLog.swift
//  niuguwang
//
//  Created by BrightLi on 2021/2/9.
//  Copyright © 2021年 taojinzhe. All rights reserved.
//

import Foundation

@objcMembers public class SLog: NSObject
{
   dynamic public class func debug(_ message : Any ..., file : String = #file, method : String = #function, line : Int = #line)
    {
        #if DEBUG
        if message.count<1{
            return
        }
        var args = message
        guard let format:String = args.removeFirst() as? String else{
            return
        }
        var info = format
        if args.count>0{
            if let params = args as? [CVarArg]{
                info = String(format: format, arguments: params)
            }
        }
        let fileName = (file as NSString).lastPathComponent
        let output = ("[\(fileName):\(method)]\(line):\(info)")
        print(output.removingPercentEncoding ?? "")
        #endif
    }
    
    dynamic public class func stackLog(_ reason:String)
    {
        let place = SOCExtend.stackPlace()!
        SLog.debug("reason=%@,place=%@",reason,place)
    }
    
    dynamic public class func stackExp(_ exception:NSException)
    {
        let place = SOCExtend.stackPlace()!
        let name = exception.name.rawValue
        let reason = exception.reason!
        SLog.debug("\nname=%@\nreason=%@\nplace=%@",name,reason,place)
    }
}


